<template>
	<view class="page">
 
 
		<view class="form">
			<u--form labelPosition="top" :model="item" :labelStyle="{width: '300rpx'}" :rules="rules" ref="uForm">
				<u-form-item label="群发内容" prop="content" :required="true" borderBottom >
					<u--textarea v-model="item.content" border="none" placeholder="请输入需要通知群发的内容"></u--textarea>
				</u-form-item>
			</u--form>
			
			
			<u-button @click="submit" :disabled="submitDisabled" customStyle="background-color: #ffd91d">提交</u-button>
		</view>
 
	</view>
</template>

<script>
	import * as Config from '@/utils/config.js'  
	import * as EventApi from '@/api/event.js';
 
	export default {
		 
		data() {
            return {
				item:{
						'content':"",
						'eventid':"",
						'memberid':uni.getStorageSync('user_id')
					  },
				rules: {
					'item.content': {
						required: true,
						message: '请填通知内容',
						trigger: ['blur', 'change']
					},
			 
				}  	
			}
		},
		onLoad(e) { 
			this.item.eventid=e.id
		},
		onShow() {
		},

		methods: {
			
			submit() {

			 
				this.$refs.uForm.validate().then(res => {
					
					console.log("item",this.item)
					console.log("res",res)
				
				 
					EventApi.creatnotice(this.item).then(res => {
						//uni.$u.toast(res.info)
						if (res.status == 200) {
							console.log("提交成功")
							setTimeout(() => {
								uni.redirectTo({
									url: '/pages/activity/manage'
								})
							}, 1000)
						} else {
							this.submitDisabled = false
							uni.$u.toast(res.status)
							console.log(res)
						}

					})
				}).catch(errors => {
					uni.$u.toast('请正确填写资料')

				})
			},
  

		},
		onReady() {
			//如果需要兼容微信小程序，并且校验规则中含有方法等，只能通过setRules方法设置规则。
			this.$refs.uForm.setRules(this.rules)
		},
	}
</script>

<style scoped lang="scss">
	@import url("asset/style.css");
</style>